﻿@if (ViewData["TagCloud"] != null)
{
    IEnumerable<CodeStash.Models.TagCloud.TagCategoryModel> cats =
        (IEnumerable<CodeStash.Models.TagCloud.TagCategoryModel>)ViewData["TagCloud"];

    if (cats.Any())
    {
        <div class="gadget">
            <h3>Tag Cloud</h3>
            <div class="clr">
            </div>
            <div id="tagCloud">
            
                @foreach (var t in cats)
                {
                    Random rand = (Random)ViewData["Rand"];
                    string[] colors = new string[] { "#007F0E", "#00AD11", "#00CE11", "#FFA500", "#FF9300", "#FF4E00" };

                    <span>
                        @Html.ActionLink(string.Format("{0}",t.CategoryName),"DisplaySnippetsForCategory","CodeSnippet",
                        new { category= t.CategoryName},
                        new 
                        { 
                            style=string.Format("color : {0}",colors[rand.Next(colors.Length)]),
                            @class = CodeStash.Utils.WebSiteUtils.GetTagClass(t.CountOfCategory, t.TotalArticles)
                        })
                    </span><span> </span>
                }
            </div>
    </div>
    }
}